/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lamhnhServlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author user
 */
@WebServlet(name="ViewProfile", urlPatterns={"/ViewProfile"})
public class ViewProfile extends HttpServlet {
   
    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        String user = request.getParameter("txtuser");
        String pass = request.getParameter("txtpass");
        boolean min = Boolean.parseBoolean(request.getParameter("txtmin"));
        String fname = request.getParameter("txtfname");
        String lname = request.getParameter("txtlname");
        String sex = request.getParameter("txtsex");
        String add = request.getParameter("txtadd");
        String rd = request.getParameter("txtrd");
        String ld = request.getParameter("txtld");
        RequestDispatcher r1 = request.getRequestDispatcher("lamServletHeader.jsp");
        RequestDispatcher r2 = request.getRequestDispatcher("admin/adminFooter.jsp");
//            out.println("<html>");
//            out.println("<head>");
//            out.println("<title>ViewProfile</title>");
//            out.println("</head>");
//            out.println("<body>");
            out.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><link rel='stylesheet' type='text/css' href='css/clientTemplate.css'><title>Member List</title></head><body><center><table id='tableClientTemplate'><tr id='headerClientTemplate' style='background-color: orange'><td>");
            r1.include(request, response);
            out.println("</td></tr><tr id='middleClientTemplate'><td>");
            out.println("<table align='center' border='1'>");
            out.println("<form action='deleteMemberServlet' method='POST'>");
            out.println("<tr>");
            out.println("<td>");
            out.println("User Name:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtuser' readonly value='"+user+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("Password:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtpass' readonly value='"+pass+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("First Name:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtfname' readonly value='"+fname+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("Last Name:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtlname' readonly value='"+lname+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("Sex:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtsex' readonly value='"+sex+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("Address:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtadd' readonly value='"+add+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("Is Administrator:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtmin' readonly value='"+min+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("Register Date:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtrd' readonly value='"+rd+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("Last Action Date:");
            out.println("</td>");
            out.println("<td>");
            out.println("<input type='text' name='txtld' readonly value='"+ld+"' />");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            out.println("<td>");
            out.println("<input type='submit' value='Delete This User' />");
            out.println("</td>");
            out.print("<td>");
            out.print("<a href='admin/MemberList.jsp'>Cancel</a>");
            out.print("</td>");
            out.println("</tr>");
            out.println("</form>");
            out.println("</table>");
            out.println("</td></tr><tr id='footerClientTemplate'><td>");
            r2.include(request, response);
            out.println("</td></tr></table></center></body></html>");
//            out.println("</body>");
//            out.println("</html>");

    } 

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    } 

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
